<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Object类型</title>
</head>
<body>
<script>
    var obj = {
        kill: function(){
            console.log("I'll kill you")
        },
        save: function(){
            console.log("I'll save your lite")
        }
    }
    with(obj){
        kill()
        save()
    }

    var cat = new Object();
    cat.food = 'fish';
    cat.sport = 'jump and run';
    cat.say = function(){
        console.log('喵喵喵！');
    }
    cat.say();  //"喵喵喵"
    console.log('cat eat ' + cat.food + ', it always ' + cat.sport)

    var dog = {
        food: 'meat',
        sport: 'run here run there',
        say: function(){
            console.log('汪汪汪');
        }
    }
    dog.say();
    console.log('dog eat ' + dog.food + ', it always ' + dog.sport)

    console.log(dog.food)  // meat
    console.log(cat['sport'])  // jump and run

</script>
</body>
</html>